//发送实体识别的请求
import Axios from 'axios'
import {nerURL} from './config'
//创建http对象
let http = Axios.create({
    baseURL: nerURL,
    headers: {
        'Content-Type': 'application/x-www-form-urlencoded'
    },
    transformRequest: [function(data) {
        let ret = ''
        for (let it in data) {//解析data并拼接
            ret += encodeURIComponent(it) + '=' + encodeURIComponent(data[it]) + '&'
        }
        return ret
    }],
})
 
///请求拦截
http.interceptors.request.use(config => {
    //拦截请求，并在请求前加上一些总是要传递的值，避免每个地方都加这个值
    //let idvalue = localStorage.getItem("idvalue")
    //config.url = config.url + '&idvalue=' +idvalue
    return config
}, err => {
    return Promise.reject(err)
})
//响应拦截
http.interceptors.response.use(response => {
    if (response.status == 200) {
        //判断是否成功响应，成功响应值=1，这个响应变量，需要前后端约定好，例如code=1：代表成功，或者code=200代表成功，
        /*if(response.data.code == 200){
 
        }*/
        return response.data
    } else {
        return Promise.reject(response)
    }
}, err => {
    return Promise.reject(err)
})
 
export default {//可供调用的方法：get，post，其它自行添加
    get(url, params) {
        let config = {
            method: 'get',
            url: url
        }
        //console.log(config)
        if (params) config.params = params
        return http(config)
    },
    post(url, params) {
        let config = {
            method: 'post',
            url: url
        }
        if (params) config.data = params
        return http(config)
    }
}


export  function
    //首页
    getEntity(params) {
        return http.get('/getEntity/'+`${params}`)
    }
import request from './chataxios'
const api = async (data) => {
    return await request({
        ...data,
    })
    }
export function chat(data) {
    return api({
        url: '/chat',
        method: 'POST',
        data: data,
    })
}